﻿<%@ Page Language="C#" MasterPageFile="~/Themes/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Goods>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%=Model.Title%>---商品详情面
</asp:Content>

<asp:Content ID="CssContent" ContentPlaceHolderID="CssContent" runat="server">
	<link href="<%=Url.Content("~/Style/Store.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Style/jquery.jqzoom.css")%>" rel="stylesheet" type="text/css" />
</asp:Content>

<asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="<%=Url.Content("~/js/jquery.jqzoom-core.js")%>" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('a#thumbsZoom').jqzoom();

            $('#goodsSKUs span').click(function () {
                $(this).addClass("selected").siblings("span").removeClass("selected");
                initPrice();
            });

            $('#goodsSKUs > li').find('span:first').click();
        });
        
        function initPrice() {
            var attrs = $('#goodsSKUs span.selected');
            if (attrs.size() == $('#goodsSKUs > li').size()) {
                var data = [];
                attrs.each(function(i, v) {
                    data.push($(v).attr('pid')+","+$(v).attr('vid'));
                });

                $.post('<%=Url.Action("GetSKUPrice","Ajax")%>', { 'goodsId': '<%=Model.ID%>', 'skus': data.join('|') }, function (price) {
                    $("#goods_price").html("￥" + price.Price);
                }, 'json');
            }
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div class="store">
		<div class="header">
			<a href="<%=Url.Action("Index", "Store", new { id = Model.ShopID })%>" class="logo">
                <img src="<%=Model.GetShop().LogoURL%>" />
            </a>
			<div class="name"><%=Model.GetShop().FullName%></div>
			<div class="domain">http://<%=Model.GetShop().SecondlevelDomain%>.luko.cn</div>
		</div>
		<div class="nav">
			<dl>
                <dd class="select">产品信息</dd>
                <dd><%=Html.ActionLink("店铺首页", "Index", "Store", new { id = Model.ShopID }, null)%></dd>
                <dd><%=Html.ActionLink("店铺动态", "News", "Store", new { id = Model.ShopID }, null)%></dd>
			</dl>
		</div>
		<div class="content">
			<div class="left">
				<%Html.RenderPartial("StoreWidget", Model.GetShop());%>

                <%
                    ViewDataDictionary viewDate = new ViewDataDictionary();
                    viewDate["Count"] = 15;
                    Html.RenderPartial("StoreRecomGoods", Model.GetShop(), viewDate);
                %>
                
			</div>
            
			<div class="right">
				<div id="basicinfo">
                    <div id="propic">
                    <% 
                    List<GoodsImage> images = Model.GetMajorImages();
                    if (images != null && images.Count > 0){ 
                    %>
						<div class="picbox">
							<a rel="gal1" id="thumbsZoom" href="<%=images.First().ImgURL.Replace("small_","")%>">
					            <img class="thumbsZoom" src="<%=images.First().ImgURL%>">
					        </a>
						</div>
						<div class="smallimg">
                            <a class="zoomThumbActive" href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '<%=images.First().ImgURL%>',largeimage: '<%=images.First().ImgURL.Replace("small_","")%>'}">
                                <img src='<%=images.First().ImgURL%>'>
                            </a>
                            <%foreach(GoodsImage img in images.Skip(1).ToList()){%>
                            <a href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: '<%=img.ImgURL %>',largeimage: '<%=img.ImgURL.Replace("small_","")%>'}">
                                <img src='<%=img.ImgURL %>'>
                            </a>
                            <%}%>
                        </div>
                    <%} %>
                    </div>
					<div id="basicitem">
                        <h1><%=Model.Title%></h1>
                        <p>
                            <b>价格：</b><span id="goods_price" class="price">￥<%=Model.Price%></span>
                            <span>（最终价格以厂家实时价格为准）</span>
                        </p>
                        <p><b>品牌：</b><%=Model.Title%></p>
                        <p><b>货号：</b><%=Model.Title%></p>
                        <p><b>代发货号：</b><%=Model.Title%></p>
                        <p><b>上架时间：</b><%=Model.OnsaleTime.ToDateTime().ToString("yyyy-MM-dd HH:mm:ss")%></p>
                        <p><b>数据下载次数：</b><%=Model.DownCount%></p>
                        <%; %>
                        <ul class="attr" id="goodsSKUs">
                            <% foreach (var skus in Model.GetSKUDate().GroupBy(c=>c.CategoryPropName)){%>
                            <li key="<%=skus.Key%>">
                                <b><%=skus.Key%></b>
                                <% foreach (var skuValue in skus){%>
                                    <span pid="<%=skuValue.Pid%>" vid="<%=skuValue.Vid %>"><%=skuValue.Name%></span>
                                <%}%>
                            </li>
                            <%}%>
                        </ul>
                        <div class="btns">
                            <div style="color:#BFBFBF;">
                                <span class="fr">路口客户QQ</span>
                                <span>若下载有问题，请联系我们</span>
                            </div>
                            <a href="#">发布到淘宝</a>
                            <%=Html.ActionLink("下载图片包", "ImageData", "Download", new { ID = Model.ID }, new { target = "_blank" })%>
                            <%=Html.ActionLink("一键代发", "AddGoods", "Cart", new { ID = Model.ID }, null)%>
                        </div>
                    </div>
				</div>
                <div id="moreinfo">
                    <h3><div>产品详情</div></h3>
                    <div class="goods_attr">
                        <%foreach (var group in Model.GetAttrs().GroupBy(c=>c.CategoryPropName)) {%>
                        <div class="item">
                            <span class="key"><%=group.Key %>：</span>
                            <%foreach (var attr in group){%>
                            <span><%=attr.Name %></span>
                            <%} %>
                        </div>
                        <%} %>
                        <div class="clear"></div>
                    </div>
                    <div class="goods_detail"><%=Model.Description%></div>
                </div>
			</div>
		</div>
	</div>
</asp:Content>
